sdk_generate_library()
sdk_add_include_directories(common)
sdk_add_include_directories(osal)
sdk_add_include_directories(core)
sdk_add_include_directories(class/cdc)
sdk_add_include_directories(class/hid)
sdk_add_include_directories(class/msc)
sdk_add_include_directories(class/audio)
sdk_add_include_directories(class/video)
sdk_add_include_directories(class/hub)

sdk_add_compile_definitions(-DCONFIG_CHERRYUSB)

if(CONFIG_CHERRYUSB_DEVICE)
sdk_library_add_sources(core/usbd_core.c)

if((NOT ("${CHIP}" STREQUAL "bl702")))
sdk_add_compile_definitions(-DCONFIG_USB_ALIGN_SIZE=32)
#sdk_library_add_sources(port/bl_usb/bl_usbdev.c)
if(CONFIG_USB_HS)
sdk_add_compile_definitions(-DCONFIG_USB_HS)
endif()
else()
if(CONFIG_USB_HS)
message(FATAL_ERROR "BL702 USB do not support high speed")
endif()
endif()

if(CONFIG_CHERRYUSB_DEVICE_CDC)
sdk_library_add_sources(class/cdc/usbd_cdc.c)
endif()
if(CONFIG_CHERRYUSB_DEVICE_HID)
sdk_library_add_sources(class/hid/usbd_hid.c)
endif()
if(CONFIG_CHERRYUSB_DEVICE_MSC)
sdk_library_add_sources(class/msc/usbd_msc.c)
endif()
if(CONFIG_CHERRYUSB_DEVICE_AUDIO)
sdk_library_add_sources(class/audio/usbd_audio.c)
endif()
if(CONFIG_CHERRYUSB_DEVICE_VIDEO)
sdk_library_add_sources(class/video/usbd_video.c)
endif()

elseif(CONFIG_CHERRYUSB_HOST)
sdk_library_add_sources(core/usbh_core.c)
sdk_library_add_sources(port/ehci/usb_hc_ehci.c)
sdk_library_add_sources(osal/usb_osal_freertos.c)
sdk_library_add_sources(class/cdc/usbh_cdc_acm.c)
sdk_library_add_sources(class/msc/usbh_msc.c)
sdk_library_add_sources(class/hid/usbh_hid.c)
sdk_library_add_sources(class/hub/usbh_hub.c)
sdk_library_add_sources(class/video/usbh_video.c)
sdk_library_add_sources(class/audio/usbh_audio.c)

sdk_add_link_libraries(
-ucdc_acm_class_driver 
-uhid_class_driver 
-umsc_class_driver 
-uvideo_ctrl_class_driver 
-uaudio_ctrl_class_driver)

endif()